package ${package};

import ${packageBase}.core.builder.Page;
import ${packageBase}.core.dao.BaseDao;
import ${packageBase}.core.exception.ImsException;
import ${packageBase}.core.jooq.tables.pojos.${className};
import ${packageBase}.core.jooq.tables.records.${className}Record;
import ${packageBase}.core.model.PageInfo;
import ${packageBase}.core.utils.TransformUtils;
import ${packageBase}.${module}.service.${className}Service;
import org.jooq.impl.DSL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;

import static ${packageBase}.core.jooq.tables.${className}.${tableName?upper_case};

/**
 * ${tableComment} 服务接口实现层
 *
 * @author motorfu
 * @email ffu@maxleap.com
 * @since ${date}
 */
@Service
public class ${className}ServiceImpl implements ${className}Service {

  private final BaseDao<${className}, ${className}Record> ${classNameSmall}BaseDao;

  @Autowired
  public ${className}ServiceImpl(BaseDao<${className}, ${className}Record> ${classNameSmall}BaseDao) {
    this.${classNameSmall}BaseDao = ${classNameSmall}BaseDao;
  }

  @Override
  public ${className} create(${className} entity) {
    return ${classNameSmall}BaseDao.create(entity);
  }

  @Override
  public int remove(Long id) {
    return ${classNameSmall}BaseDao.remove(id);
  }

  @Override
  public int removes(Long... ids) {
    return ${classNameSmall}BaseDao.removes(ids);
  }

  @Override
  public int removes(List<Long> ids) {
    return ${classNameSmall}BaseDao.removes(ids);
  }

  @Override
  public ${className} find(Long id) {
    return ${classNameSmall}BaseDao.find(id);
  }

  @Override
  public ${className} modify(${className} entity) {
    return ${classNameSmall}BaseDao.modify(entity);
  }

  @Override
  public List<${className}> findList(Integer limit) {
    if (limit != null && limit.intValue() > 0) {
      return ${classNameSmall}BaseDao.findList(limit);
    }
    return ${classNameSmall}BaseDao.findList(DSL.condition("1=1"));
  }

  @Override
  public List<${className}> findList() {
    return findList(null);
  }

  @Override
  public PageInfo<${className}> findPage(Page page) {
    return ${classNameSmall}BaseDao.findPage(page);
  }

}
